﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;
namespace ECommerce.DAO.Cache.Personas
{
    public static class Cliente
    {
        public static ECommerce.Model.Personas.Cliente GetClienteById(Int32 Id)
        {
            ECommerce.Model.Personas.Cliente Cliente = new ECommerce.Model.Personas.Cliente();
            try
            {
                Cliente = (ECommerce.Model.Personas.Cliente)HttpRuntime.Cache["Cliente-" + Id.ToString()];
            }
            catch (Exception ex)
            {
                Cliente = null;
            }
            if (Cliente.Id == 0)
                Cliente = null;
            return Cliente;
        }
        public static int SetCliente(ECommerce.Model.Personas.Cliente Cliente)
        {
            try
            {
                HttpRuntime.Cache.Insert("Cliente-" + Cliente.Id.ToString(), Cliente);
            }
            catch (Exception ex)
            {
            }
            return Cliente.Id;
        }
        public static int DelCliente(ECommerce.Model.Personas.Cliente Cliente)
        {
            try
            {
                HttpRuntime.Cache.Remove("Cliente-" + Cliente.Id.ToString());
            }
            catch (Exception ex)
            {
            }
            return Cliente.Id;
        }

     }
}
